Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
geojson-equality-ts
Advanced tools
Check two valid geojson geometries for equality.
This library is a fork of geojson-equality by Gagan Bansal (@gagan-bansal), ported to Typescript by Samir Shah (@solarissmoke). Published and maintained going forward by James Beard (@smallsaucepan).
npm install geojson-equality-ts
Use as either a class or function.
import { geojsonEquality, GeojsonEquality } from "geojson-equality";
// ... create g1 and g2 GeoJSON objects
geojsonEquality(g1, g2, { precision: 3 }); // returns boolean
const eq = new GeojsonEquality({ precision: 3 });
eq.compare(g1, g2); // returns boolean
In more detail.
const GeojsonEquality = require("geojson-equality");
const eq = new GeojsonEquality();
const g1: Polygon = {
type: "Polygon",
coordinates: [
[
[30, 10],
[40, 40],
[20, 40],
[10, 20],
[30, 10],
],
],
},
g2: Polygon = {
type: "Polygon",
coordinates: [
[
[30, 10],
[40, 40],
[20, 40],
[10, 20],
[30, 10],
],
],
};
eq.compare(g1, g2); // returns true
const g3: Polygon = {
type: "Polygon",
coordinates: [
[
[300, 100],
[400, 400],
[200, 400],
[100, 200],
[300, 100],
],
],
};
eq.compare(g1, g3); // returns false
precision number floating point precision required. Defualt is 17.
const g1: Point = { type: "Point", coordinates: [30.2, 10] };
const g2: Point = { type: "Point", coordinates: [30.22233, 10] };
geojsonEquality(g1, g2, { precision: 3 }); // returns false
geojsonEquality(g1, g2, { precision: 1 }); // returns true
direction boolean direction of LineString or Polygon (orientation) is ignored if false. Default is false.
const g1: LineString = {
type: "LineString",
coordinates: [
[30, 10],
[10, 30],
[40, 40],
],
},
g2: LineString = {
type: "LineString",
coordinates: [
[40, 40],
[10, 30],
[30, 10],
],
};
geojsonEquality(g1, g2, { direction: false }); // returns true
geojsonEquality(g1, g2, { direction: true }); // returns false
compareProperties boolean when comparing features, take their properties into account. Default is true.
const g1: Feature<Point> = {
type: "Feature",
geometry: {
type: "Point",
coordinates: [30, 10],
},
properties: { foo: "bar" },
},
g2: Feature<Point> = {
type: "Feature",
geometry: {
type: "Point",
coordinates: [30, 10],
},
properties: { foo: "BAZZZZ" },
};
geojsonEquality(g1, g2); // returns false
geojsonEquality(g1, g2, { compareProperties: false }); // returns true
Once you run
npm install
then for running test
npm run test
to create build
npm run build
PRs are welcome.
This project is licensed under the terms of the MIT license.
FAQs
Check two valid geojson geometries for equality.
The npm package geojson-equality-ts receives a total of 117,231 weekly downloads. As such, geojson-equality-ts popularity was classified as popular.
We found that geojson-equality-ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.